using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace QuanLyHocPhi.Model.Mapping
{
    public class HocKyMap : EntityTypeConfiguration<HocKy>
    {
        public HocKyMap()
        {
            // Primary Key
            this.HasKey(t => t.MaHocKy);

            // Properties
            this.Property(t => t.MaNamHoc)
                .HasMaxLength(11);

            this.Property(t => t.MaHocKy)
                .IsRequired()
                .HasMaxLength(50);

            // Table & Column Mappings
            this.ToTable("HocKy");
            this.Property(t => t.MaNamHoc).HasColumnName("MaNamHoc");
            this.Property(t => t.MaHocKy).HasColumnName("MaHocKy");
            this.Property(t => t.TenHocKy).HasColumnName("TenHocKy");

            // Relationships
            this.HasOptional(t => t.NamHoc)
                .WithMany(t => t.HocKyList)
                .HasForeignKey(d => d.MaNamHoc);

        }
    }
}
